package com.liaowei.user.openfeign;

import com.liaowei.common.BaseResponse;
import com.liaowei.model.domain.Post;
import com.liaowei.user.config.OpenFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.constraints.Min;
import java.util.List;

@FeignClient(value = "post-content-service", configuration = OpenFeignConfig.class)
public interface PostClient {
    // 根据id查询帖子信息
    @GetMapping("/contents/posts/{postId}")
    BaseResponse<Post> postVoById(@PathVariable Long postId);

    // 根据userId查询帖子数量
    @GetMapping("/contents/posts/count/{userId}")
    BaseResponse<Long> countOfPostByUserId(@PathVariable
                                           @Min(value = 1, message = "请输入合法的id")
                                           Long userId);

    // 通过id列表查询帖子列表
    @PostMapping("/contents/posts/pageByIds")
    BaseResponse<List<Post>> pageByIds(@RequestBody List<Long> postIds);
}
